<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>${version.id == null ? '添加' : '编辑'}版本</title>
    <%@include file="../../include/commonFile.jsp" %>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/form.css">
</head>
<body>
<!--头部-->
<%@include file="../../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">
            <!-- 正文请写在这里 -->
            <div class="add-form-content">
                <form id="myForm" class="layui-form mt20" method="post" action="${ctx}/system/versionMgr/save.do">
                    <input type="hidden" name="id" value="${version.id}"/>
                    <div class="layui-form-item">
                        <label class="layui-form-label">应用类型名<span class="f-verify-red">*</span></label>
                        <div class="layui-input-block">
                            <input type="text" name="type" class="layui-input" value="${version.type}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">是否开启<span class="f-verify-red">*</span></label>
                        <div class="layui-input-block">
                            <input type="radio" name="isOpen" value="1" title="是"
                            ${version == null || version.isOpen == 1 ? 'checked="checked"' : ''}
                            >
                            <input type="radio" name="isOpen" value="0" title="否"
                            ${version != null && version.isOpen == 0 ? 'checked="checked"' : ''}
                            >
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">版本号<span class="f-verify-red">*</span></label>
                            <div class="layui-input-inline">
                                <input type="text" name="versionNumber" class="layui-input"
                                       value="${version.versionNumber}">
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">描述</label>
                        <div class="layui-input-block">
                            <input type="text" name="remarks" class="layui-input" value="${version.remarks}">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button class="layui-btn layui-btn-danger" lay-submit lay-filter="*">立即提交</button>
                            <a href="${ctx}/circle/tag/list.do?circle=${circleId}" class="layui-btn layui-btn-primary">取消</a>
                        </div>
                    </div>
                </form>
            </div>
        </div><!--底部-->
        <%@include file="../../include/footer.jsp" %>
    </section>
</div>

<script>
    $(function () {
        layui.use(['form'], function () {
            var form = layui.form;

            //监听提交
            form.on('submit', function (data) {
                txz.submitObject(data.elem, function (callBack) {
                    var action = $("#myForm").attr("action");
                    $.post(action, $('#myForm').serialize(), function (res) {
                        typeof callBack === 'function' && callBack();
                        if (res.success) {
                            util.layerMsgSuccess("提交成功", function () {
                                location.href = "${ctx}/system/versionMgr/list.do";
                            });
                        } else {
                            util.layerMsgError("提交失败")
                        }
                    });
                });
                return false;
            });
        });
    })
</script>
<script type="text/javascript">
    txz.initHeader({
        nav: [{
            name: '第三方应用版本管理',
            href: '${ctx}/system/versionMgr/list.do'
        }, {
            name: '${version == null ? '创建' : '编辑'}版本',
            curr: true
        }],
        btns: [{
            name: '返回',
            href: 'javascript:history.back();',
            icon: 'back'
        }]
    });
</script>
</body>
</html>